<template>
	<view class="balance-page">
		<!-- 零钱金额显示 -->
		<view class="balance-card">
			<view class="balance-amount">
				<text class="amount">{{ balance.toFixed(2) }}</text>
				<text class="yuan">元</text>
			</view>
			<view class="balance-tip">当前零钱余额</view>
			<!-- 提现和充值按钮 -->
			<view class="action-buttons">
				<u-button class="action-btn" type="warning" shape="circle" @click="handleWithdraw">提现</u-button>
				<u-button class="action-btn" type="primary" shape="circle" @click="handleRecharge">充值</u-button>
			</view>
		</view>
		<!-- 折叠显示，按时间进行分类 -->
		<view class="u-demo-area">
			<u-toast ref="uToast"></u-toast>
			<u-collapse v-if="key" :item-style="itemStyle" event-type="close" :arrow="arrow" :accordion="accordion"
				@change="change">
		<!-- 		<u-collapse-item :index="index" @change="itemChange" :title="item.head" v-for="(item, index) in itemList"
					:key="index"> -->
					<u-collapse-item :index="index" @change="itemChange" :title="monthKey" v-for="(monthData, monthKey) in itemList"
								:key="monthKey">
					<view>
					  <view v-for="(item, index) in monthData" :key="index" class="resume-item">
					    <view class="resume-header">
					      <text class="user-name">{{ item.body }}</text>
					      <text class="position">投递：{{ item.Number }}</text>
					    </view>
					    <view class="resume-info">
					      <text>{{ item.age }}年 | {{ item.education }} | {{ item.experience }}年 | {{ item.certificate }}</text>
					    </view>
					    <view class="resume-footer">
					      <text class="time">投递时间：{{ item.time }}</text>
					      <text class="status" :class="{'unviewed': item.status === '未查看', 
					                            'viewed': item.status === '已查看',
					                            'interview': item.status === '已邀面试',
					                            'rejected': item.status === '不合适'}">状态：{{ item.status }}</text>
					    </view>
					  </view>
					</view>
					<!-- 内容结束 -->
				</u-collapse-item>
			</u-collapse>
		</view> 

	</view>
</template>

<script>
	export default {
		data() {
			return {
				balance: 0.00, // 零钱余额		
				
				//按时间分类 
				itemList: {
        "2025.4": [
          {
            head: "2025年4月",
            body: "充值",
            Number: "-25.00",
            time: "4月26日",
            status: "已退款",
            show: false
          }
        ],
        "2025.5": [
          {
            head: "2025年5月",
            body: "充值",
            Number: "25.00",
            time: "5月20日",
            status: "已支付",
            show: false
          }
        ],
        "2025.6": [
          {
            head: "2025年4月",
            body: "充值",
            Number: "-25.00",
            time: "4月26日",
            status: "已退款",
            show: false
          },
          {
            head: "2025年5月",
            body: "充值",
            Number: "25.00",
            time: "5月20日",
            status: "已支付",
            show: false
          }
        ]
      },
				accordion: true,
				arrow: true,
				hoverClass: 'hover2',
				itemStyle: {},
				key: true,
			}
		},
		methods: {
			change(e) {
				console.log(e);
			},	
			// 提现操作
			handleWithdraw() {
				uni.navigateTo({
					url: '/pages/money/withdraw'
				})
			},
			// 充值操作
			handleRecharge() {
				uni.navigateTo({
					url: '/pages/recharge/index'
				})
			}
		},
		onShow() {
			// 页面显示时获取零钱余额
			this.getBalance()
		},
		methods: {
			// 获取零钱余额（模拟）
			getBalance() {
				// 实际项目中这里应该是调用接口获取数据
				// this.$u.api.getBalance().then(res => {
				//   this.balance = res.data.balance
				// })

				// 模拟数据
				this.balance = 0.00
			},
			handleWithdraw() {
				uni.navigateTo({
					url: '/pages/Practitioner/money/withdraw'
				})
			},
			handleRecharge() {
				uni.navigateTo({
					url: '/pages/recharge/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.balance-page {
		background-color: #f5f5f5;
		min-height: 100vh;
		padding: 10rpx;
		
		////////////
			/deep/ .u-demo-area {
				margin: 5px 20px;
				
			}
			
			.example-body {
				flex-direction: column;
				flex: 1;
			}		
		
			.first{
				display: flex;
				justify-content: space-between; /* 子项分别靠左右两端对齐 */
			}
			
			.second{
				display: flex;
				justify-content: space-between; /* 子项分别靠左右两端对齐 */
			}
		
			.text {
				font-size: 14px;
				color: #666;
				line-height: 20px;
				float: right;
			}
		
			.button {
				// margin-top: 10px;
				margin: 10px;
				margin-bottom: 0;
			}
		//////////

		.balance-card {
			background-color: #fff;
			border-radius: 16rpx;
			padding: 120rpx 40rpx;
			margin-top: 4rpx;
			text-align: center;
			box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);

			.balance-amount {
				display: flex;
				justify-content: center;
				align-items: flex-end;
				margin-bottom: 20rpx;

				.amount {
					font-size: 72rpx;
					font-weight: bold;
					color: #333;
					line-height: 1;
				}

				.yuan {
					font-size: 36rpx;
					color: #666;
					margin-left: 10rpx;
					padding-bottom: 10rpx;
				}
			}

			.balance-tip {
				font-size: 28rpx;
				color: #999;
			}
		}

		.action-buttons {
			display: flex;
			justify-content: space-between;
			margin-top: 60rpx;

			.action-btn {
				width: 48%;
				height: 90rpx;
				border-radius: 45rpx;
				font-size: 32rpx;

				/deep/ .u-btn--warning.u-btn--plain {
					border-color: #f29100;
					color: #f29100;
				}
			}
		}

		.head {
			font-size: 30rpx;
			color: $u-main-color;
			line-height: 1;
			padding: 24rpx 24rpx;
		}

		.body {
			font-size: 28rpx;
			// color: $u-tips-color;
			color: red;
			line-height: 1.4;
			padding: 24rpx;
		}
	}
</style>